home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- int chk(got, expect, message)
- long got, expect;
- char *message;
- {
- if(got != expect)
- {
- fprintf(stderr, "Expecting %ld Got %ld (%s)\n", expect, got, message);
- return 1;
- }
- return 0;
- }
-
- #define FILENAME "twrseek.tst"
- main()
- {
- FILE *fp;
- int status = 0;
- long got;
-
- #ifdef atarist
- _binmode(1);
- #endif
- if(!(fp = fopen(FILENAME,"w+")))
- {
- perror(FILENAME);
- exit(1);
- }
-
- got = fseek(fp,100L,0);
- status |= chk(got, 0L, "fseek(fp, 100L, 0)");
-
- fwrite("a",1,1,fp);
- got = ftell(fp);
- status |= chk(got, 101L, "ftell(fp)");
-
- fseek(fp,200L,0);
- fwrite("a",1,1,fp);
- got = ftell(fp);
- status |= chk(got, 201L, "ftell(fp) after fwrite");
-
- fseek(fp,100L,0);
- got = fgetc(fp);
- status |= chk(got, (long)'a', "fgetc(fp)");
-
- fseek(fp,150L,0);
- got = fgetc(fp);
- status |= chk(got, 0L, "fgetc(fp)@150");
-
- fclose(fp);
- unlink(FILENAME);
-
- return status;
- }
-